package messages;
import sharedspace.*;

/**
 * This message purpose is to give back all the user's details when he logs on
 * @author Avishai
 *
 */
public class MessageLoginReply extends Message {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public enum LoginStatus {
	    LOGGED_IN,
	    LOGIN_FAIL
	}

	public enum Permission {
		GUEST,
	    STUDENT,
	    TEACHER,
	    MANAGER,
	    ADMIN	    
	}
	
	public enum ErrMsg{
		SUCCESS,
		INCORRECT,
		ALREADY_LOGIN,
		UNKNOWN,
		FROZEN, 
		DELETED,
	}
	
	public enum AccountType{
		GUEST,
		ONE_TIME_PAYMENT,
		MONHLY_PAYMENT,
		YEARLY_PAYMENT,
		IRRELEVANT
	}
	
	private User userLog;
	private ErrMsg error;
	

	
	
	public String[] ErrMsg={"Success","Username Or Password are incorrect","You are already logged in to the system","Your account has been deleted by Admin","Your account is frozen","Username does not exist or is not fully detailed, please contact your administrator"};
	
	/**
	 * 
	 * @param stat
	 * @param perm Permission type
	 * @param Err 	Error Message (only if the user didn't log on)
	 * @param a_type Account Type
	 * @param user
	 * @param pass
	 * @param name
	 * @param accNum
	 */
	public MessageLoginReply(User user,ErrMsg Err) {
		super(Message.MessageType.MESSAGE_LOGIN_REPLY);
		
		userLog = user;
		error=Err;
		
	
	}
	
	/**
	 * 
	 * @param n Account number
	 */
	
	

	
	/**
	 * 
	 * @param n index to get an Error message
	 * @return Error Message (String)
	 */
	public String GetErrorMessage(int n)
	{
		switch (error){
		case SUCCESS :
		{
			return ErrMsg[n];
		}		
		case INCORRECT:
		{
			return ErrMsg[n];
		}
		
		case ALREADY_LOGIN:
		{
			return ErrMsg[n];
		}
		case FROZEN:
		{
			return ErrMsg[n];
		}
		case UNKNOWN:
		{
			return ErrMsg[n];
		}
		default:
			return ErrMsg[n];
		}
	}
	
	/**
	 * 
	 * @return Account Type
	 */
	

	/**
	 * 
	 * @param user
	 */
	public void setUser(User user)
	{
		this.userLog=user;
	}
	
	/**
	 * 
	 * @param pass 
	 */
	
	/**
	 * 
	 * @return Error message
	 */
	public ErrMsg getError()
	{
		return error;
	}
	/**
	 * 
	 * @return userLog
	 */
	public User getUser()
	{
		return userLog;
	}
}